package com.movitech.mobile.cz.base.supplier.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.plugins.Page;
import com.movitech.mobile.cz.base.supplier.entity.SEvaluationPerson;
import com.movitech.mobile.cz.base.supplier.service.SEvaluationPersonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
 * <p>
 * SEvaluationPerson 前端控制器
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-02-28
 */
@RestController
@RequestMapping("/v1/sEvaluationPerson")
@Api(value = "供方评估--供方评估人员基础操作接口", description = "供方评估--供方评估人员基础操作接口")
public class SEvaluationPersonController {
    @Autowired
    @Qualifier("sEvaluationPersonService")
    private SEvaluationPersonService sEvaluationPersonService;

    @GetMapping("/allList")
    @ApiOperation(
            value = "获取所有供方评估--供方评估人员接口",
            notes = "获取所有供方评估--供方评估人员接口",
            response = SEvaluationPerson.class
    )
    public RestReturnResult list() {
        RestReturnResult restReturnResult = RestReturnResult.success();
        Page<SEvaluationPerson> page = sEvaluationPersonService.selectPage(new Page<SEvaluationPerson>());
        restReturnResult.setData(page);
        return restReturnResult;
    }

    @PostMapping("/searchList/{pageNumber}")
    @ApiOperation(
            value = "供方评估--供方评估人员列表查询接口",
            notes = "供方评估--供方评估人员列表查询接口",
            response = SEvaluationPerson.class
    )
    public RestReturnResult searchList(@RequestBody SEvaluationPerson sEvaluationPerson,
                @ApiParam(value = "分页页数")@PathVariable Integer pageNumber) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        Page<SEvaluationPerson> page = new Page<>();
        page.setCurrent(pageNumber);
        EntityWrapper wrapper = new EntityWrapper<>();
        wrapper.setEntity(sEvaluationPerson);
        page = sEvaluationPersonService.selectPage(page,wrapper);
        restReturnResult.setData(page);
        return restReturnResult;
    }

    @GetMapping("/getSEvaluationPerson/{id}")
    @ApiOperation(
            value = "供方评估--供方评估人员对象ID获取接口",
            notes = "供方评估--供方评估人员对对象ID获取接口",
            response = SEvaluationPerson.class
    )
    public RestReturnResult addSEvaluationPerson(@PathVariable String id) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        SEvaluationPerson sEvaluationPerson = sEvaluationPersonService.selectById(id);
        restReturnResult.setData(sEvaluationPerson);
        return restReturnResult;
    }

    @PostMapping("/add")
    @ApiOperation(
            value = "供方评估--供方评估人员添加接口",
            notes = "供方评估--供方评估人员添加接口",
            response = SEvaluationPerson.class
    )
    public RestReturnResult add(@RequestBody SEvaluationPerson sEvaluationPerson) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sEvaluationPersonService.insert(sEvaluationPerson);
        restReturnResult.setData(sEvaluationPerson);
        return restReturnResult;
    }

    @PutMapping("/update")
    @ApiOperation(
            value = "供方评估--供方评估人员更新接口",
            notes = "供方评估--供方评估人员更新接口",
            response = SEvaluationPerson.class
    )
    public RestReturnResult update(@RequestBody SEvaluationPerson sEvaluationPerson) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sEvaluationPersonService.updateById(sEvaluationPerson);
        restReturnResult.setData(sEvaluationPerson);
        return restReturnResult;
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(
            value = "供方评估--供方评估人员通过ID删除接口",
            notes = "供方评估--供方评估人员通过ID删除接口",
            response = SEvaluationPerson.class
    )
    public RestReturnResult update(@PathVariable String id) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sEvaluationPersonService.deleteById(id);
        return restReturnResult;
    }


}

